<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/8/17
  Time: 16:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <base href="${pageContext.request.contextPath}/">
    <title>修改学员信息</title>
</head>
<body>
<form action="StudentUpdateServlet?sid=${sessionScope.student.sid}" method="post">
    <table align="center" border="1px">
        <tr style="background: darkgray">
            <td colspan="2"><h1 align="center">学员信息</h1></td>
        </tr>
        <tr align="center">
            <td>学员姓名</td>
            <td><input type="text" name="sname" id="sname" value="${sessionScope.student.sname}"></td>
        </tr>
        <tr align="center">
            <td>学员性别</td>
            <td><input type="text" name="sgender" id="sgender" value="${sessionScope.student.sgender}"></td>
        </tr>
        <tr align="center">
            <td>学员年龄</td>
            <td><input type="text" name="sage" id="sage" value="${sessionScope.student.sage}"></td>
        </tr>
        <tr align="center">
            <td>家庭住址</td>
            <td><input type="text" name="saddres" value="${sessionScope.student.saddress}"></td>
        </tr>
        <tr align="center">
            <td>Email</td>
            <td><input type="text" name="semail" value="${sessionScope.student.semail}"></td>
        </tr>
        <tr>
            <td align="center" colspan="2"><input type="submit" value="修改"></td>
        </tr>
    </table>
    <script src="jq/jquery.js"></script>
    <script>
        $('form').submit(function () {
            var flag = true;
            if(!SName()) flag=false;
            else if(!SGender()) flag=false;
            else if(!SAge()) flag=false;
            return flag
        })

        //验证姓名
        function SName() {
            if($('#sname').val() == ""){
                alert('学员姓名不能为空');
                return false
            }
            return true
        }
        //验证性别
        function SGender() {
            if($('#sgender').val() == ""){
                alert('学员性别不能为空');
                return false
            }
            return true
        }
        //验证年龄
        function SAge() {
            if($('#sage').val() == ""){
                alert('学员年龄不能为空');
                return false
            }
            return true
        }
    </script>
</form>
</body>
</html>
